package com.zhanghe.study.springmvc.controller;

import com.zhanghe.study.springmvc.dto.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * 消息解析测试
 * @author zh
 * @date 2021/1/9 15:30
 */
@Controller
@RequestMapping("/json")
public class JsonController {

    @ResponseBody
    @RequestMapping("/testJson")
    public User testJson(){
        User user = new User();
        user.setName("张三");
        user.setId(2);
        return user;
    }

    @ResponseBody
    @RequestMapping("/testException")
    public User testException(){
        User user = null;
        user.setName("张三");
        user.setId(2);
        return user;
    }

    @ResponseBody
    @RequestMapping("/testMap")
    public User testMap(TestMap testMap){
        User user = null;
        user.setName("张三");
        user.setId(2);
        return user;
    }

    static class TestMap{
        private Map<String,Object> params;

        public Map<String, Object> getParams() {
            return params;
        }

        public void setParams(Map<String, Object> params) {
            this.params = params;
        }
    }
}
